var a = require("../../../@babel/runtime/helpers/defineProperty"), t = getApp(), e = require("../../../mybehaviors/location/location");

Page({
    behaviors: [ e ],
    data: {
        showLocation: !1,
        activeName: 0,
        isLoading: !1,
        dataList: [ {
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            list: []
        }, {
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            list: []
        } ],
        isLoadMore: !0,
        titleArr: [ "离我最近", "好评优先" ],
        lat: 0,
        lng: 0,
        city: "",
        point: {
            lat: "",
            lng: ""
        }
    },
    onLoad: function(a) {
        var t = this;
        a.city && "1" !== a.city ? (a.city && this.setData({
            city: a.city
        }), a.point && this.setData({
            point: JSON.parse(a.point)
        }), this.handleClick()) : this._getLocation(function() {
            t.handleClick();
        });
    },
    onReady: function() {},
    tabClick: function(a) {
        this.setData({
            activeName: a.detail.index
        }), this.handleClick();
    },
    handleClick: function() {
        var e = this;
        if (this.data.dataList[e.data.activeName].list.length > 0) e.data.isLoadMore = this.data.dataList[e.data.activeName].isLoadMore; else {
            var i = t.getNetAddresss("plugin.fight-groups.frontend.store.store-fight-arrondi.get-fight-groups");
            t._getNetWork({
                url: i,
                data: {
                    page: 1,
                    type_id: e.data.activeName + 1,
                    lng: e.data.point.lng,
                    lat: e.data.point.lat
                },
                success: function(t) {
                    var i, o = t.data;
                    1 == o.result ? e.setData((a(i = {}, "dataList[" + e.data.activeName + "].isLoadMore", !0), 
                    a(i, "dataList[" + e.data.activeName + "].total_page", o.data.last_page), a(i, "dataList[" + e.data.activeName + "].list", o.data.data), 
                    i)) : wx.showToast({
                        title: o.msg,
                        icon: "none",
                        duration: 1e3
                    });
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    goGroup: function(a) {
        var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.storeid;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + t + "/" + e + "&name=group"
        });
    },
    gotoO2oHome: function(a) {
        var t = a.currentTarget.dataset.storeid;
        wx.navigateTo({
            url: "/packageC/o2o/HomeSeller/HomeSeller?store_id=" + t
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.dataList[this.data.activeName].isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var e = this;
        if (this.setData(a({}, "dataList[" + e.data.activeName + "].isLoadMore", !1)), !(this.data.dataList[this.data.activeName].page >= this.data.dataList[this.data.activeName].total_page)) {
            this.data.dataList[this.data.activeName].page = this.data.dataList[this.data.activeName].page + 1;
            var i = t.getNetAddresss("plugin.fight-groups.frontend.store.store-fight-arrondi.get-fight-groups");
            i += "&page=" + this.data.dataList[this.data.activeName].page, t._getNetWork({
                url: i,
                data: {
                    page: e.data.page,
                    type_id: e.data.activeName + 1,
                    lng: e.data.lng,
                    lat: e.data.lat
                },
                success: function(t) {
                    var i = t.data;
                    if (1 == i.result) {
                        var o, s = i.data;
                        e.setData((a(o = {}, "dataList[" + e.data.activeName + "].isLoadMore", !0), a(o, "dataList[" + e.data.activeName + "].list", e.data.dataList[e.data.activeName].list.concat(s.data)), 
                        o));
                    } else {
                        var d;
                        e.setData((a(d = {}, "dataList[" + e.data.activeName + "].isLoadMore", !1), a(d, "dataList[" + e.data.activeName + "].page", e.data.dataList[e.data.activeName].page - 1), 
                        d));
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});